<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    return view('welcome');
});

Route::get('home', 'HomeController@index');

//登录注册
Route::get('login', 'Auth\LoginController@showLoginForm')->name('login');
Route::post('auth/login', 'Auth\LoginController@login');


Route::post('auth/logout', 'Auth\LoginController@logout');

//后台登录
Route::get('admin/login', 'Admin\LoginController@showLoginForm');
Route::post('admin/login', 'Admin\LoginController@login');
Route::get('admin/logout', 'Admin\LoginController@logout');
Route::get('admin/verify', 'Admin\LoginController@verifyImg');

Route::group(['prefix' => 'admin', 'namespace' => 'Admin', 'middleware'=>'auth.admin'], function (){
    //后台管理
    Route::get('', 'IndexController@index');
    Route::get('home', 'IndexController@home');
    Route::get('resetPassword', 'LoginController@showResetForm');
    Route::post('resetPassword', 'LoginController@resetPassword');
    Route::get('test', 'IndexController@test');
    //管理员管理
    Route::resource('adminuser', 'AdminController');
    Route::resource('roles', 'RoleController');
    Route::patch('roleAdd/{admin}', 'AdminController@roleAdd');
    Route::resource('permissions', 'PermissionsController');
    //老师管理
    Route::get('teacher/find', 'TeacherController@findTeacher');
    Route::resource('teacher', 'TeacherController');
    Route::resource('groups', 'TeacherGroupsController');
    //会员管理
    Route::resource('children', 'ChildrenController');
    Route::get('child/find', 'ChildrenController@findChildren');
    Route::get('child/findOne/{child}', 'ChildrenController@findOne');
    //添加小朋友到班级
    Route::post('child/classes/{class}', 'ChildrenController@childToClasses');
    Route::post('child/sign/{class}/{child}/{course}', 'ClassesController@sign');
    Route::post('child/retroactive/{class}/{child}/{age}/{weekday}/{week}', 'ClassesController@retroactive');
    Route::get('child/classes/{class}', 'ChildrenController@addChild');
    Route::resource('users', 'UsersController');
    Route::resource('children', 'ChildrenController');
    Route::post('children/search', 'ChildrenController@index');
    //课程管理
    Route::get('course/find', 'CourseController@findCourse');
    Route::get('course/create/{subject}', 'CourseController@create');
    Route::resource('course', 'CourseController');
    Route::resource('classes', 'ClassesController');
    Route::resource('subject', 'CourseSubjectController');
    Route::get('course/findmore/{subject}', 'CourseController@findCourseMore');
    Route::get('consume/history', 'ConsumesController@classesHistory');
    Route::post('consume/history', 'ConsumesController@classesHistory');
    //消费管理
    Route::get('users/card/{user}', 'CardController@create');
    Route::resource('cards', 'CardController');
    Route::get('consumes', 'ConsumesController@consumesList');
    Route::post('consumes/find', 'ConsumesController@consumesList');
    Route::get('card/list/{child}', 'CardController@cardList');
    //系统管理
    Route::get('logs', 'AdminController@getLogs');
    Route::post('logs', 'AdminController@getLogs');
    Route::get('test', 'IndexController@test');
});